//
//  XHUIImageTestViewController.m
//  testApp
//
//  Created by ColdMountain on 2017/3/6.
//  Copyright © 2017年 ColdMountain. All rights reserved.
//

#import "XHUIImageTestViewController.h"

#import "XHTestImageViewCell.h"

#import "Services.h"

#import <SDWebImage/UIImageView+WebCache.h>
#import <UIImageView+CornerRadius.h>

@interface XHUIImageTestViewController ()
@property (weak, nonatomic) IBOutlet UITableView *ui_tableView;
@property (strong, nonatomic) NSArray * m_array;

@end

@implementation XHUIImageTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.ui_tableView registerNib:[UINib nibWithNibName:@"XHTestImageViewCell" bundle:nil] forCellReuseIdentifier:XHTestImageViewCellIdentifier];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self banner];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)banner
{
    [ServiceManager postBannerWithSuccess:^(NSDictionary *data) {
        self.m_array=(NSArray*)data;
        [self.ui_tableView reloadData];
    } failure:^(NSDictionary *data) {
        
    }];
}

#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 40;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = nil;
    cell = [self imageViewCell:indexPath];
    return cell;
}

- (XHTestImageViewCell *)imageViewCell:(NSIndexPath*)indexPath
{
    XHTestImageViewCell * cell = [self.ui_tableView dequeueReusableCellWithIdentifier:XHTestImageViewCellIdentifier];
    NSDictionary * dic = self.m_array[indexPath.row];
    [cell.ui_imageView sd_setImageWithURL:[NSURL URLWithString:dic[@"imageurl"]]];
    [cell.ui_imageView1 sd_setImageWithURL:[NSURL URLWithString:dic[@"imageurl"]]];
    [cell.ui_imageView2 sd_setImageWithURL:[NSURL URLWithString:dic[@"imageurl"]]];
    [cell.ui_imageView3 sd_setImageWithURL:[NSURL URLWithString:dic[@"imageurl"]]];
    
    return cell;
}


#pragma - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat height=300;
    return height;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
